// pages/order/order.js
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';

Page({
  data: {
    orderList:[]
  },

  onLoad: function (options) {
    this.switchTab(options.type)
  },

  onShow: function (options) {
  },

  switchTab(type){
    var that = this;
    wx.request({
      url: "http://127.0.0.1:8000/order/",
      method: "GET",
      data: {//get 方法下的数据格式
        type:type,
        token:wx.getStorageSync('token')
      },
      header: {
          'content-type': "json"
      },
      success: function (res) {
        if (res.data.status > 0) {
          wx.showLoading({
            title : '加载中...',
            mask : true
          })
          that.setData({orderList:res.data.orderList})
          wx.hideLoading()
        }else if(res.data.status == -1){
          wechat.wxLogin()
        }
      },
      fail: function (error) {
        Toast('获取数据失败');
      }
    })
  }


})